﻿/////////////////////////////////////////////////////////////////////
//
//	Map_FVG C# Class Library.
//
//	insNodiDlg
//	
//
//	autore: Gustavo Mainardi 
//	versione: 1.0
//	data: 01/12/2015
//
//
//	Cronologia delle versioni:
//
//	Versione 1.0 01/12/2015
//		versione originale
//
//////////////////////////////////////////////////////////////////////////
using System;
using System.Windows.Forms;

namespace Map_Fvg
{
    public partial class insNodiDlg : Form
    {
        private static int opt;
        private static int num;
        public static int insert_point;
        public static int select_point;

        public insNodiDlg()
        {
            InitializeComponent();

            int isel = ViewQ.selected_linea;
            textBox1.Text = isel.ToString();
            num = ViewQ.vectShapes[isel].nVertices;
            textBox2.Text = num.ToString();

            textBox3.Text = insert_point.ToString();
            select_point = 0;
            opt = 0;
        }

        private void radioButton1_CheckedChanged(object sender, EventArgs e)
        {
            if (radioButton1.Checked)
            {
                radioButton2.Checked = false;
                radioButton3.Checked = false;
            }
            opt = 1;
            insert_point = 0;
        }

       private void radioButton2_CheckedChanged(object sender, EventArgs e)
        {
            if (radioButton2.Checked) 
            {
                radioButton1.Checked = false;
                radioButton3.Checked = false;
            }
            opt = 2;

            insert_point = num; 
        }

       private void radioButton3_Click(object sender, EventArgs e)
       {
           if (radioButton3.Checked)
           {
               radioButton1.Checked = false;
               radioButton2.Checked = false;
           }
           opt = 3;
       }

        private void button1_Click(object sender, EventArgs e)
        {

            this.Close();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            if(opt == 0)
            {
                MessageBox.Show("selezionare un'opzione");
                return;
            }

            ViewQ.option_selected = 7;
            ViewQ.inserimento_modo = 3;
            if (opt == 3)
            {
                string ss = textBox3.Text;
                int inum = int.Parse(ss);
                if (inum > num)
                {
                    MessageBox.Show("non esiste il nodo di inserzione " + ss);
                    return;
                }
                insert_point = inum;
            }

            this.Close();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            select_point = 1;
            ViewQ.option_selected = 3;
            ViewQ.newPnt = 0;
            this.Close();
        }



 
    }
}
